#!/bin/bash

CmakeFlags=""
for param in "$@"
do
  case $param in
        asan) CmakeFlags=${CmakeFlags}" -DAsan=on ";;
        release) CmakeFlags=${CmakeFlags}" -DCMAKE_BUILD_TYPE=Release ";;
        atlas) CmakeFlags=${CmakeFlags}" -DCMAKE_TOOLCHAIN_FILE=./crossCompile.cmake";;
  esac
done

while getopts :cp:t opt
do
   case "$opt" in
     c)  clean=1;;
     *) echo "Unknown option: $opt";;
   esac
done

if [ 0 -ne $clean ]; then
  rm -rf $(pwd)/build
  mkdir -p build
fi

mkdir -p build
cd build
cmake $CmakeFlags ..
make -j8



